﻿@page "/Orders/{orderId:int}"
@using Microsoft.AspNetCore.Authorization

@attribute [Authorize]

<h1>Bestellung @orderId</h1>

<MudGrid>

    <MudItem xs="12" sm="6" md="4">
        <MudPaper Elevation="2" Class="pa-4" Style="height: 200px;">
            <MudText Typo="Typo.h6">Datum</MudText>
            <MudText>@order.DateOrdered Uhr</MudText>
            <MudText Typo="Typo.h6">Summe</MudText>
            <MudText>@order.Total.ToString("C")</MudText>
            <MudText Typo="Typo.h6">Status</MudText>
            <MudText>@order.Status</MudText>
        </MudPaper>
    </MudItem>

    @*
    <MudItem xs="12" sm="6" md="4">
        <MudPaper Elevation="2" Class="pa-4" Style="height: 200px;">
            <MudText Typo="Typo.h6">Zahlungsart</MudText>
            <MudText>@order.PaymentMethod</MudText>
            <MudText Typo="Typo.h6">Zahlungsanbieter</MudText>
            <MudText>@order.PaymentProvider</MudText>
            <MudText Typo="Typo.h6">Zahlungsstatus</MudText>
            <MudText>@order.PaymentStatus</MudText>
        </MudPaper>
    </MudItem>
    *@

    <MudItem xs="12" sm="6" md="4">
        <MudPaper Elevation="2" Class="pa-4" Style="height: 200px;">
            <MudText Typo="Typo.h6">Rechnungsadresse</MudText>
            <MudText>
                @order.InvoiceAddressFirstName @order.InvoiceAddressLastName<br />
                @if (@order.InvoiceAddressCompanyName.Length > 0)
                {
                    @order.InvoiceAddressCompanyName<br />
                }
                @order.InvoiceAddressStreet<br />
                @order.InvoiceAddressZip @order.InvoiceAddressCity
            </MudText>
        </MudPaper>
    </MudItem>

    <MudItem xs="12" sm="6" md="4">
        <MudPaper Elevation="2" Class="pa-4" Style="height: 200px;">
            <MudText Typo="Typo.h6">Lieferaddresse</MudText>
            <MudText>
                @order.DeliveryAddressFirstName @order.DeliveryAddressLastName<br />
                @if(@order.DeliveryAddressCompanyName.Length > 0)
                {
                    @order.DeliveryAddressCompanyName<br />
                }
                @order.DeliveryAddressStreet<br />
                @order.DeliverAddressZip @order.DeliveryAddressCity
            </MudText>
        </MudPaper>
    </MudItem>
</MudGrid>

<MudPaper Class="p-4 mt-4">
    <MudText Typo="Typo.h6">Artikel</MudText>
    <MudDataGrid Items="@order.OrderItems" SortMode="SortMode.Single">
        <Columns>
            <PropertyColumn Property="x => x.Name" Title="Produkt" />
            <PropertyColumn Property="x => x.Quantity" Title="Menge" />
            <PropertyColumn Property="x => x.Price" Title="Preis" Format="C" />
            <PropertyColumn Property="x => x.Quantity * x.Price" Title="Summe" Format="C" />
        </Columns>
    </MudDataGrid>
</MudPaper>